using System;
using System.Drawing.Drawing2D;
using System.Data;
using System.Data.Odbc;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Reviewer.Entities.Services;
using Reviewer.Business;

public partial class V2Controls_Nyhedsbrev : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.uiLblMessage.Visible = false;
        }
    }
    protected void uiTbNewsLetterSignup_Click(object sender, EventArgs e)
    {
        Page.Validate("NewsLetter");
        if (Page.IsValid)
        {
            string email = this.uiTbNewsLetterEmail.Text;
            if (!String.IsNullOrEmpty(email))
            {
                using (INewsletterService service = ServiceFactory.NewsletterService)
                {
                    if (service.IsSignedUp(email))
                    {
                        this.uiLblMessage.Visible = true;
                        this.uiLblMessage.Text = "Du er allerede tilmeldt";
                        UiUtillity.ScrollIntoView(this.uiLitScrollIntoView);
                    }
                    else
                    {
                        service.Signup(email);
                        this.uiLblMessage.Visible = true;
                        this.uiLblMessage.Text = "Tak - du er nu tilmeldt!<br />Du kan altid afmelde dig igen, ved at bruge linket i Nyhedsbrevet.";
                        this.uiPlhSignup.Visible = false;
                        UiUtillity.ScrollIntoView(this.uiLitScrollIntoView);
                    }
                }
            }
        }
    }
}
